<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
String path = request.getContextPath();
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>库存列表</title>
    <link href="<%=path%>/css/core.css" rel="stylesheet" type="text/css"/>
    <link href="<%=path%>/css/pagination.css" rel="stylesheet" type="text/css"/>
    <link href="<%=path%>/css/list.css" rel="stylesheet" type="text/css"/>
    <link href="<%=path%>/css/xToolbar.css" rel="stylesheet" type="text/css"/>
    <link href="<%=path%>/css/jquery-impromptu.css" rel="stylesheet" type="text/css"/>
  </head>
  <body>
    <div id="toolbar"></div>
    <form id="listForm" action="<%=path%>/product/stock/chooseBack.t4m" method="post">
      <s:hidden name="searchType"/>
      <div class="search-div">
        <div class="search-condition">
          <table class="search-table" cellspacing="0" cellpadding="0">
            <tr>
              <td class="c-left">所在仓库：</td>
              <td><input name="searchValue" type="text" class="text" value="<s:property value="searchValue[0]"/>"/></td>
              <td class="c-left">货品名称：</td>
              <td><input name="searchValue" type="text" class="text" value="<s:property value="searchValue[1]"/>"/></td>
            </tr>
          </table>
        </div>
        <div class="search-commit">
          <a href="javascript:void(0)" class="search-button" onclick="$('#searchType').val('and');$('#listForm').submit();">与查询</a>
          <a href="javascript:void(0)" class="search-button" onclick="$('#searchType').val('or');$('#listForm').submit();">或查询</a>
        </div>
      </div>
      <table id="titleTable" cellpadding="0" cellspacing="0">
        <tr>
          <td>&nbsp;</td>
          <td><input type="checkbox" id="allBox"/></td>
          <td>货品编号</td>
          <td>货品名称</td>
          <td>货品类别</td>
          <td>规格型号</td>
          <td>生产商</td>
          <td>供应商</td>
          <td>采购价格</td>
          <td>所在仓库</td>
          <td>退货数量</td>
          <td style="display: none;"></td>
        </tr>
      </table>
      <table id="dataTable" cellpadding="0" cellspacing="0">
        <s:iterator id="object" value="page.list" status="i">
          <tr class="row">
            <td class="num"><s:property value="#i.index+1"/></td>
            <td class="box">
              <input type="checkbox" name="idList" value="<s:property value="#object.id"/>"/>
            </td>
            <td><span><s:property value="#object.product.code"/></span></td>
            <td><span><s:property value="#object.product.name"/></span></td>
            <td><span><s:property value="#object.product.productType.name"/></span></td>
            <td><span><s:property value="#object.product.standard"/></span></td>
            <td><span><s:property value="#object.product.manufacturer"/></span></td>
            <td><span><s:property value="#object.inOrder.arriveOrder.purchaseOrder.supplier.name"/></span></td>
            <td><span><s:property value="#object.inOrderProduct.inPrice"/>&nbsp;</span></td>
            <td><span><s:property value="#object.warehouse.name"/>&nbsp;</span></td>
            <td><span><s:property value="#object.backAmounts"/>&nbsp;</span></td>
            <td style="display: none;"><s:property value="#object.product.id"/></td>
          </tr>
        </s:iterator>
      </table>
      <s:include value="/share/pagebar.jsp"/>
    </form>
    
    <script src="<%=path%>/js/core.js" type="text/javascript"></script>
    <script src="<%=path%>/js/share.js" type="text/javascript"></script>
    <script src="<%=path%>/js/jquery.js" type="text/javascript"></script>
    <script src="<%=path%>/js/Grid.js" type="text/javascript"></script>
    <script src="<%=path%>/js/BoxSelect.js" type="text/javascript"></script>
    <script src="<%=path%>/js/xToolbar.js" type="text/javascript"></script>
    <script src="<%=path%>/js/xToolbar.items.js" type="text/javascript"></script>
    <script src="<%=path%>/js/jquery-impromptu.js" type="text/javascript"></script>
    <script type="text/javascript">
    
    $(document).ready(function(){
    
      var toolbar = new Toolbar({
        id: '1',
        renderTo : 'toolbar',
        icon: '../../image/op.gif',
        items : [{
          type : 'button',
          text : '选择',
          useable : 'T',
          position: {
            a: '0px 0px',
            b: '0px -120px'
          },
          handler : function(){
            if(getFirstID()) {
              var dataArray = [];
              var datas = $('#dataTable tr.selected');
              datas.each(function(i){
                var tds = $('td', this);
                dataArray[i] = {
                  id: tds.eq(1).children('input[name="idList"]').val(),
                  pCode: tds.eq(2).text(),
                  pName: tds.eq(3).text(),
                  pStandard: tds.eq(5).text(),
                  pManufacturer: tds.eq(6).text(),
                  pSupplier: tds.eq(7).text(),
                  pPrice: tds.eq(8).text(),
                  stockBackAmounts: $.trim(tds.eq(10).text()),
                  pId: tds.eq(11).text()
                };
              });
              parent.opener.addData(dataArray);
	          parent.close();
            }
          }
        },'-',{
          type : 'search'
        }]
      });
      
      new Grid({
        titleTable:'titleTable',
        dataTable:'dataTable',
        widths : [30,24,100,100,100,100,80,80,60,80,60],
        height : function(){return getGridHeight({toolbarId:'toolbar',hasPage:true});}
      });

      new BoxSelect({
        allId : 'allBox',
        boxName : 'idList'
      });
      
      loadReady();
    });
    </script>
  </body>
</html>